<template>
	<uni-nav-bar title="烟草包装鉴定" statusBar></uni-nav-bar>
	<view class="content">
		<view class="box" @click="openCamera">
			<view class="icon">
				<uni-icons type="camera" size="200" color="#ffffff"></uni-icons>
			</view>
				<view class="text-font">
					<text>正&nbsp;反&nbsp;鉴&nbsp;定</text>
				</view>
		</view>
	</view>
</template>

<script setup>
import ycStore from '/Store/store.js' 
import {uploadImage} from "../../request/request.js"
const ycstore=ycStore()
const takePhoto=()=> {
	console.log("准备拍照");
	uni.chooseImage({
		sourceType: ['camera'],
		success: (res) => {
			ycstore.mark=1
			console.log("加载中...")
			const tempFilePaths = res.tempFilePaths;
			console.log("拍照成功");
			uploadImage(tempFilePaths[0]);
			// 处理拍摄成功后的逻辑，tempFilePaths为拍摄的照片临时文件路径
		},
		fail: (err) => {
			console.error('拍照失败', err);
		}
	});
}
const openCamera=()=> {
	plus.android.requestPermissions(['android.permission.CAMERA'], (e) => {
		if (e.deniedAlways.length > 0) {    //权限被永久拒绝  
			// 弹出提示框解释为何需要权限，引导用户打开设置页面开启  
			console.log('权限被永久拒绝' + e.deniedAlways.toString());
		}
		if (e.deniedPresent.length > 0) {   //权限被临时拒绝  
			// 弹出提示框解释为何需要权限，可再次调用plus.android.requestPermissions申请权限  
			console.log('权限被临时拒绝' + e.deniedPresent.toString());
		}
		if (e.granted.length > 0) { //权限被允许  
			console.log('权限被允许' + e.granted.toString());
			takePhoto();
		}
	}, (e) => {
		console.log('Request Permissions error:' + JSON.stringify(e));
	});
}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		
	}
	.box {
	margin-top: 50rpx;
	  width: 600rpx;
	  height: 600rpx;
	  border: 1rpx solid #ccc; /* 1像素宽的实线边框，颜色为灰色 */
	  border-radius: 200rpx; /* 设置圆角半径为5像素 */
	  display: flex; /* 使用 flex 布局 */
	  flex-direction: column; /* 垂直方向排列 */
	  align-items: center; /* 沿交叉轴居中对齐 */
	  background-color: #409eff;
	}
	.icon{
		margin-top: 10rpx;
		
	}
	.text-font{
		font-size: 70rpx;
		color: #ffffff;
	}
</style>
